<template>
  <div class="block">
    <span class="demonstration">完整功能</span>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="page_obj.pageNum"
      :page-sizes="[3, 5, 10]"
      :page-size="100"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
  </div>
</template>
<script>
export default {
  props: {
    total: {
      type: Number,
    },
  },
  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`, val);
      this.page_obj.pageSize = Number(val);
      this.$emit("getPageObj", this.page_obj);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.page_obj.pageNum = Number(val);
      this.$emit("getPageObj", this.page_obj);
    },
  },
  created() {
    this.$emit("getPageObj", this.page_obj);
  },
  data() {
    return {
      page_obj: {
        pageSize: 3,
        pageNum: 1,
      },
    };
  },
};
</script>
